import RequestHttp from '@/utils/http'
import {
  SearchParams,
  ListResult,
  IdParams,
  PostRow,
  PostParams,
  PostStateParams,
  PostIdParams,
  BatchDestroyParams,
  VoListResult,
} from './model/postModel'

enum Api {
  index = '/api/sysPost/index', //列表
  store = '/api/sysPost/store', //添加
  show = '/api/sysPost/show', //详情
  update = '/api/sysPost/update', //修改
  state = '/api/sysPost/state', //状态
  batchDestroy = '/api/sysPost/batch/destroy', //批量删除
  destroy = '/api/sysPost/destroy', //删除
  voList = '/api/sysPost/vo/list', //下拉列表
}

export const GetList = (params?: SearchParams) => {
  return RequestHttp.get<ListResult>(Api.index, params)
}

export const Store = (params: PostParams) => {
  return RequestHttp.post<boolean>(Api.store, params)
}

export const Show = (params: IdParams) => {
  return RequestHttp.get<PostRow>(Api.show, params)
}

export const Update = (params: PostParams) => {
  return RequestHttp.put<boolean>(Api.update, params)
}

export const State = (params: PostStateParams) => {
  return RequestHttp.put<boolean>(Api.state, params)
}

export const Destroy = (params: PostIdParams) => {
  return RequestHttp.delete<boolean>(Api.destroy, params)
}

export const BatchDestroy = (params: BatchDestroyParams) => {
  return RequestHttp.delete<boolean>(Api.batchDestroy, params)
}

export const GetPostVoList = () => {
  return RequestHttp.get<VoListResult[]>(Api.voList)
}
